We investigate how the transition from integrability to nonintegrability occurs by changing the parameters of the Hamiltonian of a Heisenberg spin-1/2 chain with defects. Randomly distributed defects may lead to quantum chaos. A similar behavior is obtained in the presence of a single defect out of the edges of the chain, suggesting that randomness is not the cause of chaos in these systems, but the mere presence of a defect.